package org.gwt.grin.rebind.features;

import java.util.Formatter;

import org.gwt.grin.client.features.InterpolatedModel;
import org.gwt.grin.rebind.SECommand;
import org.gwt.grin.rebind.SEFeature;
import org.gwt.grin.rebind.ShowBuilder;

public class SETimer extends SEFeature {

	private final int numFrames;
	private final boolean repeat;
	private SECommand[] commands;

	public SETimer(String name, int numFrames, boolean repeat,
			SECommand[] commands) {
		super(name);
		this.numFrames = numFrames;
		this.repeat = repeat;
		this.commands = commands;
	}

	@Override
	public String write(ShowBuilder builder) {
		Formatter formatter = new Formatter();
		formatter.format("makeTimer(\"%s\", %d, %b, %s)", name,
				numFrames, repeat, makeCommandsArray(builder, commands));
		return formatter.toString();
	}

	@Override
	protected String getClassName() {
		return InterpolatedModel.class.getName();
	}

}
